package test.ShenxinfuTest;

import java.util.Scanner;

// 深信服笔试
public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String[] s1 = in.nextLine().split(" ");
        String[] s2 = in.nextLine().split(" ");
        int[] arr1 = new int[s1.length] ;
        int[] arr2 = new int[s2.length] ;
        int max1 = 0 , max2 = 0 ;
        for(int i = 0 ; i < s1.length ; i++){
            arr1[i] = Integer.parseInt(s1[i]);
            max1 += arr1[i];
        }

        for(int i = 0 ; i < s2.length ; i++){
            arr2[i] = Integer.parseInt(s2[i]);
            max2 += arr2[i];
        }

        int a = 0, b = 0;
        int mid = (max1 + max2) / 2 ;
        int left = max1-mid ;
        if(left > 0){
            for(int i = 0 ; i < arr1.length ; i++){
                if(left > 0 && arr1[i] <= left) continue;
                for(int j = 0 ; j < arr2.length ; j++){
                    if(max1 - arr1[i] + arr2[j] == mid ){
                        a = arr1[i] ;
                        b = arr2[j] ;
                        break;
                    }
                }
            }
        }else {
            for(int i = 0 ; i < arr2.length ; i++){
                if( arr2[i] <= left) continue;
                for(int j = 0 ; j < arr1.length ; j++){
                    if(max1 - arr1[j] + arr2[i] == mid ){
                        a = arr1[j] ;
                        b = arr2[i] ;
                        break;
                    }
                }
            }
        }

        if(a == 0 && b == 0){
            System.out.println("fail");
        }else {
            System.out.print(a + " " + b);
        }


    }
}

/*


Scanner in = new Scanner(System.in);
        String[] s1 = in.nextLine().split(" ");
        int[] arr = new int[s1.length] ;
        for(int i = 0 ; i < s1.length ; i++){
            arr[i] = Integer.parseInt(s1[i]);
        }
        //int[] arr = new int[] {7,4,5,3,1} ;

        int res = 0 ;
        int l = 0 , r = 0 ;
        for(int i = 1 ; i < arr.length ; i++){
            if(arr[i] >= arr[i-1]){
                res = Math.max(r - l + 1,res) ;
                l = r + 1;
                r++;
            }else {
                r++;
                res = Math.max(r - l + 1,res) ;
            }
        }
        System.out.println(res);
 */
